package com.mxx.common.data.domain;

import com.mxx.common.thread.FastThreadContext;

/**
 * @Author itzgyw
 * @Date 2020-02-19
 * @Time 13:22
 * @Description:
 */
public class JpaThreadContext {
    private final static String USER_ID = "jap_id";
    private final static String ADMIN_ID = "adminId";

    public static <T> void setUserId(T userId) {
        FastThreadContext.set(USER_ID, userId);
    }

    public static <T> T getUserId() {
        return FastThreadContext.getThrowNull(USER_ID, "jpa save id not found");
    }

    public static <T> boolean hasId() {
        return FastThreadContext.get(USER_ID).isPresent();
    }


    public static void removeId() {
        FastThreadContext.remove(USER_ID);
    }



}
